package com.zprmb.udzt;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.zprmb.udzt.fragment.DexterityBillFragment;
import com.zprmb.udzt.fragment.PagerSlidingTabStrip;

/**
 * 智投宝账单
 * @author shenshao
 */

public class DexterityBillActivity extends BaseActivity {

	private PagerSlidingTabStrip tabs;
	private ViewPager pager;
	private MyPagerAdapter adapter;
	private ImageView iv_v4_dexteritybill_back;
	private TextView tv_v4_dexteritybill_title;
	private RelativeLayout rl_back;

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.v4_dexteritybill_activity);
		 BbtApplication.getInstance().addActvity(this);
		initView();
	}

	private void initView() {
		tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs);
		pager = (ViewPager) findViewById(R.id.view_pager);
		adapter = new MyPagerAdapter(getSupportFragmentManager());
		// pager.setOffscreenPageLimit(2);
		pager.setAdapter(adapter);
		tabs.setViewPager(pager);
		iv_v4_dexteritybill_back = (ImageView) findViewById(R.id.img_back);
		rl_back=(RelativeLayout)findViewById(R.id.rl_back);
		rl_back.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				DexterityBillActivity.this.finish();
			}
		});
		iv_v4_dexteritybill_back.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				DexterityBillActivity.this.finish();
			}
		});
		iv_v4_dexteritybill_back.setOnClickListener(new OnClickListener() {
			public void onClick(View arg0) {
				DexterityBillActivity.this.finish();
			}
		});
		tv_v4_dexteritybill_title = (TextView) findViewById(R.id.tv_v4_dexteritybill_title);
		tv_v4_dexteritybill_title.getPaint().setFakeBoldText(true);
		tv_v4_dexteritybill_title.setText("智投宝账单");
	}

	public class MyPagerAdapter extends FragmentPagerAdapter {

		private final String[] TITLES = { "转入", "转出" };
		private final String[] STATUS = { "IN", "OUT" };

		public MyPagerAdapter(FragmentManager fm) {
			super(fm);
		}

		public CharSequence getPageTitle(int position) {
			return TITLES[position];
		}

		public int getCount() {
			return TITLES.length;
		}

		public Fragment getItem(int position) {
			return DexterityBillFragment.newInstance(position, STATUS[position]);
		}
	}

}
